From 7aacc1cab033fd77370b8d03b037892b3dd28a7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 5 Dec 2025 23:39:23 +0100 Subject: [PATCH] environment: Split out the prepare and cleanup animation code We do the same twice, and it's not trivial code anymore, so let's separate this into another function which returns the prepare and cleanup functions Part-of: --- js/ui/environment.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/js/ui/environment.js b/js/ui/environment.js index 8effcd240..64a2b4629 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -71,6 +71,19 @@ function _makeEaseCallback(params, cleanup) { }; } +function _makeEasePrepareAndCleanup() { + const prepare = () => { + global.compositor.disable_unredirect(); + global.begin_work(); + }; + const cleanup = () => { + global.compositor.enable_unredirect(); + global.end_work(); + }; + + return {prepare, cleanup}; +} + function _getPropertyTarget(actor, propName) { if (!propName.startsWith('@')) return [actor, propName]; @@ -128,14 +141,7 @@ function _easeActor(actor, params) { actor.set_easing_mode(params.mode); delete params.mode; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transitions @@ -209,14 +215,7 @@ function _easeAnimatableProperty(animatable, propName, target, params) { if (!actor?.mapped) duration = 0; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transition -- 2.39.5